﻿using System.Data.Entity.ModelConfiguration;
using OneBlog.Model.Entities;

namespace OneBlog.DataAccessLayer.ModelConfigurations
{
    public class BlogInfoMap : EntityTypeConfiguration<BlogInfo>
    {
        public BlogInfoMap()
        {
            ToTable("BlogInfo");
            Property(c => c.Content).HasMaxLength(400000);
            Property(c => c.Title).IsRequired().HasMaxLength(200);
            Property(c => c.ForUrl).HasMaxLength(200);
            Property(c => c.Url).HasMaxLength(200);

            HasMany(c => c.Comments).WithRequired(c => c.BlogInfo).HasForeignKey(c => c.BlogInfoId);

            HasMany(c => c.BlogTypes).WithMany(c => c.BlogInfos);
        }
    }
}